﻿using MusicZone.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace MusicZone.VariableTemplate
{
    public class VariableTiles : DataTemplateSelector
    {
        public DataTemplate Top20ItemTemplate { get; set; }
        public DataTemplate FeaturedPlaylistTemplate { get; set; }
        public DataTemplate ArtistBigTemplate { get; set; }
        public DataTemplate ArtistSmallTemplate { get; set; }
        public DataTemplate ArtistMoreTemplate { get; set; }
        public DataTemplate GenresSmallTemplate { get; set; }
        public DataTemplate GenresBigTemplate { get; set; }
        public DataTemplate AlbumTemplate { get; set; }
        public DataTemplate LastAddedTemplate { get; set; }
        public DataTemplate LastAddedMoreTemplate { get; set; }
        public DataTemplate FeaturedPlaylistBigTemplate { get; set; }
        public DataTemplate ArtistMediumTemplate { get; set; }
        public DataTemplate Top20BigItemTemplate { get; set; }
        public DataTemplate Top20SmallItemTemplate { get; set; }
        public DataTemplate ArtistItemTemplate { get; set; }



       


        protected override Windows.UI.Xaml.DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;
            if (item != null && element != null)
            {
                if (item.GetType() == typeof(HubPageDataItem))
                {
                    if ((item as HubPageDataItem).UniqueId.StartsWith("Top20"))
                        return Top20ItemTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("FeaturedPlaylist"))
                        return FeaturedPlaylistTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("BigFeaturedPlaylist"))
                        return FeaturedPlaylistBigTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("ArtistBig"))
                        return ArtistBigTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("ArtistSmall"))
                        return ArtistSmallTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("ArtistMore"))
                        return ArtistMoreTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("GenresSmall"))
                        return GenresSmallTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("GenresBig"))
                        return GenresBigTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("Album"))
                        return AlbumTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("LastAdded"))
                        return LastAddedTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("AddedMore"))
                        return LastAddedMoreTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("ArtistMedium"))
                        return ArtistMediumTemplate;
                }

                if (item.GetType() == typeof(Spoke1DataItem))
                {
                    if ((item as Spoke1DataItem).UniqueId.StartsWith("BigTop20"))
                        return Top20BigItemTemplate;
                    if ((item as Spoke1DataItem).UniqueId.StartsWith("SmallTop20"))
                        return Top20SmallItemTemplate;
                }

                if (item.GetType() == typeof(Spoke2DataItem))
                {
                    if ((item as Spoke2DataItem).UniqueId.StartsWith("Artist"))
                        return ArtistItemTemplate;                   
                }
            }
            return base.SelectTemplateCore(item, container);
        }
    }
}

